package com.iteaj.iot.handle.proxy;

import org.springframework.core.Ordered;

import java.lang.reflect.Proxy;

public interface ProtocolHandleProxyMatcher extends Ordered {

    boolean matcher(Object target);

    default Object createProxy(Object target) {
        final Class<?> targetClass = target.getClass();
        return Proxy.newProxyInstance(targetClass.getClassLoader()
                , targetClass.getInterfaces(), invocationHandler(target));
    }

    ProtocolHandleInvocationHandler invocationHandler(Object target);
}
